package com.mrobuy.jdvc.dao.impl;

import com.mrobuy.jdvc.dao.VCCatePropDao;
import com.mrobuy.jdvc.entity.VCCategoryProp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import java.util.Collections;
import java.util.List;


@Repository("vcCatePropDao")
public class VCCatePropDaoImpl implements VCCatePropDao {

    private static Logger LOG = LoggerFactory.getLogger(VCCatePropDao.class);

    @Autowired
    private JdbcTemplate jdbcTemplate;

    @Override
    public List<VCCategoryProp> load(String cid) {
        StringBuilder sql = new StringBuilder();
        sql.append(" SELECT * from VC_CATEGORY_PROP where CID = ? ");
        try {
            List<VCCategoryProp> list = jdbcTemplate.query(sql.toString(), new Object[]{cid}, new BeanPropertyRowMapper(VCCategoryProp.class));
            return list;
        } catch (Exception e) {
            LOG.error(e.getMessage());
        }

        return Collections.EMPTY_LIST;
    }
}
